# coding: utf-8
"""这个是自己加的"""
import numpy as np


def sigmoid(x):
    """sigmoid函数"""
    return 1 / (1 + np.exp(-x))


def identity_function(x):
    """恒等输出函数"""
    return x


class _3LNN():
    """3层神经网络"""
    def __init__(self):
        network = {}
        network['w1'] = np.array([[0.1, 0.3, 0.5], [0.2, 0.4, 0.6]])
        network['b1'] = np.array([0.1, 0.2, 0.3])
        network['w2'] = np.array([[0.1, 0.4], [0.2, 0.5], [0.3, 0.6]])
        network['b2'] = np.array([0.1, 0.2])
        network['w3'] = np.array([[0.1, 0.3], [0.2, 0.4]])
        network['b3'] = np.array([0.1, 0.2])
        self.network = network

    def forward(self, x):
        w1, w2, w3 = self.network['w1'], self.network['w2'], self.network['w3']
        b1, b2, b3 = self.network['b1'], self.network['b2'], self.network['b3']

        a1 = np.dot(x, w1) + b1
        z1 = sigmoid(a1)
        a2 = np.dot(z1, w2) + b2
        z2 = sigmoid(a2)
        a3 = np.dot(z2, w3) + b3
        y = identity_function(a3)

        return y


if __name__ == '__main__':
    _3lnn = _3LNN()
    x = np.array([1.0, 0.5])
    y = _3lnn.forward(x)
    print(y)
